<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>充值订单列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/app/admin/component/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" media="all">
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 搜索栏 -->
                <form class="layui-form" lay-filter="search-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <input type="text" name="keyword" placeholder="请输入会员卡号/手机号" class="layui-input">
                        </div>
                        <div class="layui-inline">
                            <input type="text" name="daterange" id="daterange" placeholder="请选择日期范围" class="layui-input">
                        </div>
                        <div class="layui-inline">
                            <select name="payment_method">
                                <option value="">支付方式</option>
                                <option value="1">现金</option>
                                <option value="2">微信</option>
                                <option value="3">支付宝</option>
                                <option value="4">银行卡</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn" lay-submit lay-filter="recharge-search">
                                <i class="layui-icon layui-icon-search"></i>查询
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>

                <!-- 数据表格 -->
                <table id="recharge-table" lay-filter="recharge-table"></table>
            </div>
        </div>
    </div>

    <script src="/app/admin/component/layui/layui.js"></script>
    <script>
    layui.use(['table', 'form', 'laydate'], function(){
        var table = layui.table
        ,form = layui.form
        ,laydate = layui.laydate;
        
        // 日期范围选择
        laydate.render({
            elem: '#daterange'
            ,type: 'date'
            ,range: true
        });
        
        // 表格渲染
        table.render({
            elem: '#recharge-table'
            ,url: '/app/ky_shouyin/admin/order/rechargeList'
            ,cols: [[
                {field: 'order_no', title: '订单号', width: 180}
                ,{field: 'card_no', title: '会员卡号', width: 120}
                ,{field: 'member_name', title: '会员姓名', width: 100}
                ,{field: 'member_phone', title: '手机号码', width: 120}
                ,{field: 'amount', title: '充值金额', width: 100}
                ,{field: 'give_amount', title: '赠送金额', width: 100}
                ,{field: 'payment_method', title: '支付方式', width: 100, templet: function(d){
                    var methods = {1:'现金', 2:'微信', 3:'支付宝', 4:'银行卡'};
                    return methods[d.payment_method] || '';
                }}
                ,{field: 'store_name', title: '门店', width: 120}
                ,{field: 'staff_name', title: '操作员', width: 100}
                ,{field: 'remark', title: '备注'}
                ,{field: 'created_at', title: '充值时间', width: 160, sort: true}
            ]]
            ,page: true
            ,limit: 20
            ,limits: [20, 50, 100]
            ,text: {
                none: '暂无数据'
            }
        });
        
        // 搜索
        form.on('submit(recharge-search)', function(data){
            var field = data.field;
            
            // 重载表格
            table.reload('recharge-table', {
                where: field
                ,page: {
                    curr: 1
                }
            });
            
            return false;
        });
    });
    </script>
</body>
</html> 